package com.cuit.riskassessment.action.Rv;

import javax.annotation.Resource;
import javax.servlet.http.HttpServletResponse;

import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Controller;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RequestParam;
import org.springframework.web.bind.annotation.ResponseBody;

import com.cuit.riskassessment.service.RvService;
import com.cuit.riskassessment.util.Result;
import com.cuit.riskassessment.vo.Rv;

@Controller
@RequestMapping(value = "rv")
public class RvAction {
	@Autowired
	@Resource(name = "rvService")
	private RvService rvService;

	@RequestMapping(value = "addOrUpdateRv")
	public @ResponseBody
	Object addOrUpdateRv(HttpServletResponse res, Rv rv,@RequestParam(value="projid") Integer projid) {
		Result result = new Result();
		rv.setPid(projid);
		res.setHeader("Accept", "application/json");
		if (rvService.addOrUpdateRv(rv)) {
			result.setMessage("操作成功");
			result.setSuccess(true);
		}else {
			result.setMessage("操作失败");
			result.setSuccess(false);
		}
		return result;
	}
	@RequestMapping(value = "setRv")
	public @ResponseBody
	Object setRv(HttpServletResponse res,
			@RequestParam(value = "projid") Integer projid) {
		Result result = new Result();
		res.setHeader("Accept", "application/json");
		Object obj = rvService.setRv(projid);
		if (obj==null) {
			result.setSuccess(false);
		}else {
			result.setSuccess(true);
			result.setOthers(obj);
		}
		return result;

	}
}
